package org.jeecg.modules.wms.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.system.base.entity.JeecgEntity;

import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;

/**
 * 库位信息
 */
@Data
@TableName("wms_warehouse_location")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "wms_warehouse_location对象", description = "库位信息")
public class WmsWarehouseLocation extends JeecgEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 库位ID
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "库位ID")
    private String id;

    /**
     * 仓库ID
     */
    @ApiModelProperty(value = "仓库ID")
    private String warehouseId;

    /**
     * 库位编号
     */
    @Excel(name = "库位编号", width = 15)
    @ApiModelProperty(value = "库位编号")
    private String locationCode;

    /**
     * 库位名称
     */
    @Excel(name = "库位名称", width = 15)
    @ApiModelProperty(value = "库位名称")
    private String locationName;

    /**
     * 库位二维码
     */
    @ApiModelProperty(value = "库位二维码")
    private String locationQrcode;
    
    /**
     * 库位容量
     */
    @Excel(name = "库位容量", width = 15)
    @ApiModelProperty(value = "库位容量")
    private BigDecimal capacity;

    /**
     * 状态（1:空闲,2:占用,3:锁定,4:禁用,5:已满,）
     */
    @Excel(name = "状态", width = 15, dicCode = "wms_location_status")
    @ApiModelProperty(value = "状态")
    @Dict(dicCode = "wms_location_status")
    private String status;

    /**
     * 备注
     */
    @Excel(name = "备注", width = 15)
    @ApiModelProperty(value = "备注")
    private String remark;

    /**
     * 余料库时，可以绑定物料编号，便于进行余料库位自动分配  逗号分隔
     */
    private String materialCodeList;

    /**
     * 租户ID
     */
    @ApiModelProperty(value = "租户ID")
    private String tenantId;

    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    
    /**
     * 是否强制更新二维码
     * 不作为数据库字段，仅用于前端传值控制
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "是否强制更新二维码")
    private Boolean forceUpdateQrcode;
    
    /**
     * 判断是否需要强制更新二维码
     */
    public boolean isForceUpdateQrcode() {
        return forceUpdateQrcode != null && forceUpdateQrcode;
    }

    // 添加仓库名称字段（用于导出）
    @TableField(exist = false)
    @Excel(name = "所属仓库", width = 15)
    private String warehouseName;

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    @TableField(exist = false)
    private String warehouseType;
} 